#!/usr/bin/env python2
@LOADMPIFORPY@
import sys
sys.path.append('@PYLIBDIR@')
import Sherpa

# Add this to the execution arguments to prevent Sherpa from starting the cross section integration
sys.argv.append('INIT_ONLY: 2')

Generator=Sherpa.Sherpa(len(sys.argv),sys.argv)
try:
    Generator.InitializeTheRun()
    Process=Sherpa.MEProcess(Generator)

    # Incoming flavors must be added first!
    Process.AddInFlav(11);
    Process.AddInFlav(-11);
    Process.AddOutFlav(1);
    Process.AddOutFlav(-1);
    Process.Initialize();

    # First argument corresponds to particle index:
    # index 0 correspons to particle added first, index 1 is the particle added second, and so on...
    Process.SetMomentum(0, 45.6,0.,0.,45.6)
    Process.SetMomentum(1, 45.6,0.,0.,-45.6)
    Process.SetMomentum(2, 45.6,0.,45.6,0.)
    Process.SetMomentum(3, 45.6,0.,-45.6,0.)
    print '\nSquared ME: ', Process.CSMatrixElement()

    # Momentum setting via list of floats
    Process.SetMomenta([[45.6,0.,0.,45.6],
                        [45.6,0.,0.,-45.6],
                        [45.6,0.,45.6,0.],
                        [45.6,0.,-45.6,0.]])
    print '\nSquared ME: ', Process.CSMatrixElement()
    
    # Random momenta
    E_cms = 500.0
    wgt = Process.TestPoint(E_cms)
    print '\nRandom test point '
    print 'Squared ME: ', Process.CSMatrixElement(), '\n'

except Sherpa.SherpaException as exc:
    print exc
    exit(1)
